<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>字典管理</title>
	<meta name="decorator" content="nblank"/>
</head>
<body>
<div class="content container">
	<h2 class="page-title">字典管理<small> 字典添加</small></h2>
<section class="widget widget-tabs widget-table-overflow ">
	<header>
		<ul class="nav nav-tabs">
			<li><a href="${ctx}/sys/dict/">字典列表</a></li>
			<li class="active"><a href="javascript:;">字典<shiro:hasPermission name="sys:dict:edit">${not empty dict.id?'修改':'添加'}</shiro:hasPermission><shiro:lacksPermission name="sys:dict:edit">查看</shiro:lacksPermission></a></li>
		</ul>
	</header>
		<div class="body tab-content">
			<form:form id="inputForm" modelAttribute="dict" action="${ctx}/sys/dict/save" method="post" class="form-horizontal">
				<form:hidden path="id"/>
				<sys:message content="${message}"/>
				<div class="form-group">
					<label class="control-label col-sm-4">键值:</label>
					<div class="col-sm-4">
						<form:input path="value" htmlEscape="false" maxlength="50" class="form-control input-transparent"/>
						<label id="valueScan" class="error" style="display: none;">标识已存在，请重填</label>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label col-sm-4">标签:</label>
					<div class="col-sm-4">
						<form:input path="label" htmlEscape="false" maxlength="50" class="form-control input-transparent"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label col-sm-4"><span><span style="color:red;">*</span></span> 类型:</label>
					<div class="col-sm-4">
						<form:input path="type" htmlEscape="false" maxlength="50" class="form-control input-transparent"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label col-sm-4">描述:</label>
					<div class="col-sm-4">
						<form:input path="description" htmlEscape="false" maxlength="50" class="form-control input-transparent"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label col-sm-4">排序:</label>
					<div class="col-sm-4">
						<form:input path="sort" htmlEscape="false" maxlength="11" class="form-control input-transparent"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label col-sm-4">备注:</label>
					<div class="col-sm-4">
						<form:textarea path="remarks" htmlEscape="false" rows="3" maxlength="200" class="form-control input-transparent"/>
					</div>
				</div>
				<div class="form-actions">
					<div class="text-align-center">
						<input id="btnCancel" class="btn btn-default" type="button" style="margin-left: -50px;min-width:100px;" value="返 回" onclick="history.go(-1)"/>
						<input id="btnSubmit" class="btn btn-primary" style="margin-left:50px;min-width:100px;" type="submit" value="保 存"/>&nbsp;
					</div>
				</div>
			</form:form>
			</div>
		</section>
	</div>
<script type="text/javascript">
	$(document).ready(function() {
		$("#value").focus();
		$("#value").focus(function () {
			$("#valueScan").css("display", "none");
		});
		$("#inputForm").validate({
			ignore: "",
			focusInvalid: true,
			rules: {
				"value": {required: true},
				"label": {required: true},
				"type": {required: true},
				"sort": {required: true}
			},
			errorPlacement: function (error, element) {
				error.appendTo(element.parent());
			},
			submitHandler: function(form){
				$(form).find(":submit").attr("disabled",true).attr("value", "提交中...");
				$(form).ajaxSubmit({
					success: function (result) {
						if (result == "success") {
							pxTrigDlg("${ctx}/sys/dict/?repage&type=${dict.type}");
						}
						if (result == "kidIsExist") {
							$("#valueScan").css("display", "block");
						}
					}
				})
			},
			errorContainer: "#messageBox"
		});
	});
</script>
</body>
</html>